<?php echo link_to('жагсаалт', 'video/index', array('class'=>'title'))?> 
<span class="separator"> | </span>
<?php echo link_to('шинээр нэмэх', 'video/new', array('class'=>'title'))?>
<br clear="all">
<br clear="all">


<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>

<form action="<?php echo url_for('video/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
  <table>
    <tfoot>
      <tr>
        <td colspan="2">
          <?php echo $form->renderHiddenFields(false) ?>
          <input type="submit" value="Хадгалах" />
          &nbsp;<a href="<?php echo url_for('video/index') ?>">Жагсаалтруу буцах</a>
        </td>
      </tr>
    </tfoot>
    <tbody>
      <?php echo $form->renderGlobalErrors() ?>
      <tr>
        <th><?php echo $form['season_id']->renderLabel() ?></th>
        <td>
          <?php echo $form['season_id']->renderError() ?>
          <?php echo $form['season_id'] ?><br>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['object_type']->renderLabel() ?></th>
        <td>
          <?php echo $form['object_type']->renderError() ?>
          <?php echo $form['object_type'] ?><br>
          <div id="container_object_id">&nbsp;</div>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['title']->renderLabel() ?></th>
        <td>
          <?php echo $form['title']->renderError() ?>
          <?php echo $form['title'] ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['embed']->renderLabel() ?></th>
        <td>
          <?php echo $form['embed']->renderError() ?>
          <?php echo $form['embed'] ?>
        </td>
      </tr>
    </tbody>
  </table>
</form>

<script type="text/javascript">
function loadObjects()
{
  $.ajax({
      url: "<?php echo url_for('video/loadObjects')?>",
      data: {seasonId : $('#video_season_id').val(), objectType : $('#video_object_type').val(), objectId: <?php echo $sf_request->getParameter('objectId') ? $sf_request->getParameter('objectId') : 0?>},
      type: "POST",
      success: function(data){
          $('#container_object_id').html('<select id="video_object_id" name="video[object_id]" style="width:400px;">' + data + '</select>');
      }
  });
  return false;
}

$(document).ready(function() {
    loadObjects();  
});
</script>